/*
 * 精英申请审核表单
 * @Author: along
 * @Edition: 1.3.5
 * @Date: 2020-04-20
 */
<template>
    <div class="container eliteExamline">
        <!-- header -->
        <div class="header-nav">
            <div class="header-left">
                <div class="header-new-box">
                    <p class="header-new-box-title">用户手机号、姓名或学生编号:</p>
                    <el-input
                        v-model="head.student_id_keyword"
                        placeholder="请输入内容"
                        size="small"
                        clearable
                        suffix-icon="el-icon-search"
                        @change="getTableData(1)"
                        @keyup.native.enter="getTableData(1)"
                    />
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">审核状态:</p>
                    <el-select
                        v-model="head.examine"
                        placeholder="请选择"
                        size="small"
                        @change="getTableData(1)"
                    >
                        <el-option
                            v-for="item in examineList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                        />
                    </el-select>
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">提交时间:</p>
                    <el-date-picker
                        v-model="head.date"
                        type="daterange"
                        size="small"
                        clearable
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期"
                        @change="getTableData(1)"
                    />
                </div>
            </div>
            <div class="header-right">
                <el-button
                    size="small"
                    type="primary"
                    @click="fnSetkf()"
                    v-if="is_kf_load"
                >
                    {{ !is_kf ? '添加客服' : '解绑客服' }}
                </el-button>
            </div>
        </div>
        <!-- /header -->

        <!-- table -->
        <el-table
            :data="tableData"
            height="100%"
            style="width: 100%;"
            border
            ref="eliteExamline"
            @select="fnSelect"
            @select-all="fnSelectAllTop"
            @selection-change="handleSelectionChange"
        >
            <el-table-column
                type="selection"
                width="40"
                fixed="left"
            />
            <el-table-column
                prop="true_name"
                label="用户昵称"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            />
            <el-table-column
                prop="student_no"
                label="用户编号"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            />
            <el-table-column
                prop="phone"
                label="手机号"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            />
            <el-table-column
                prop="school"
                label="学校名称"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            />
            <el-table-column
                prop="audit_status"
                label="审核状态"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            >
                <template slot-scope="scope">
                    <p v-if="scope.row.audit_status == 0">待审核</p>
                    <p v-if="scope.row.audit_status == -1">未通过</p>
                    <p v-if="scope.row.audit_status == 1">已通过</p>
                </template>
            </el-table-column>
            <el-table-column
                prop="submit_time"
                label="提交时间"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            >
                <template slot-scope="scope">
                    {{ scope.row.submit_time * 1000 | dateFormatter('yyyy/MM/dd HH:mm') }}
                </template>
            </el-table-column>
            <el-table-column
                prop="remark"
                label="备注"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            />
            <el-table-column
                prop="agent_type"
                label="精英类型"
                show-overflow-tooltip
                :formatter="emptyFormatter"
            >
                <template slot-scope="scope">
                    <span v-if="scope.row.agent_type == 1">自由精英</span>
                    <span v-else-if="scope.row.agent_type == 2">专职精英</span>
                    <span v-else>--</span>
                </template>
            </el-table-column>
            <el-table-column
                prop="agent_type"
                label="上级信息"
                show-overflow-tooltip
                :formatter="emptyFormatter"
            >
                <template slot-scope="scope">
                    <div>上级姓名：{{ scope.row.parent_true_name }}</div>
                    <div>上级电话: {{ scope.row.parent_phone }}</div>
                </template>
            </el-table-column>
            <el-table-column
                prop="apply_channel"
                label="申请渠道"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
            />
            <el-table-column
                label="学生认证"
                show-overflow-tooltip
                align="center"
            >
                <template slot-scope="scope">
                    <p v-if="scope.row.is_verify === 1">是</p>
                    <p v-else>否</p>
                </template>
            </el-table-column>
            <el-table-column
                label="操作"
                align="center"
                fixed="right"
                :width="200"
            >
                <template slot-scope="scope">
                    <el-button
                        type="text"
                        class="curse-add"
                        @click="fnEXamlineDialog(scope.row, scope.$index)"
                        v-if=" scope.row.audit_status == 0 "
                    >
                        审核
                    </el-button>
                    <el-button
                        type="text"
                        class="curse-add"
                        @click="fnSeeDialog(scope.row, scope.$index )"
                        v-if=" scope.row.audit_status !== 0 "
                    >
                        查看
                    </el-button>
                    <el-button
                        type="text"
                        class="curse-add"
                        @click="fnExamineAdopt(scope.row)"
                        :disabled=" scope.row.audit_status == 0 ? false : true "
                    >
                        通过
                    </el-button>
                    <el-button
                        type="text"
                        class="curse-add"
                        @click="fnExamineNoAdopt(scope.row, true)"
                        :disabled=" scope.row.audit_status == 0 ? false : true "
                    >
                        不通过
                    </el-button>
                    <el-button
                        type="text"
                        class="curse-add"
                        @click="fnBeizhu(scope.row)"
                    >
                        备注
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
        <!-- /table -->

        <!-- 审核-查看弹窗 -->
        <el-dialog
            :visible.sync="dialogVisible"
            width="620px"
            :close-on-click-modal="false"
        >
            <div class="zd-examine">
                <div class="zd-examine-list">
                    <p class="zd-head-title">当页进度:</p>
                    <div class="zd-examine-line" >
                        <p
                            :style="{ width: 200 * (pageIndex + 1) / pageSize + 'px' }"
                            class="zd-examine-line-length"
                        />
                    </div>
                    <p class="zd-examine-page">{{ (pageIndex + 1) + '/' + pageSize }}</p>
                </div>
                <div class="zd-examine-list">
                    <p class="zd-head-title">{{ dialog_status ? '审核' : '查看' }}内容:</p>
                    <div class="zd-info">
                        <p class="zd-info-label">姓名: {{ dialogData.true_name }}</p>
                        <p class="zd-info-label">年龄: {{ dialogData.birth_year | filterYear }}</p>
                        <p class="zd-info-label">性别: {{ dialogData.sex == 0 ? '女' : '男' }}</p>
                        <p class="zd-info-label">手机号: {{ dialogData.contact_phone }}</p>
                        <p class="zd-info-label">QQ号: {{ dialogData.contact_qq }}</p>
                        <p class="zd-info-label">微信号: {{ dialogData.contact_weixin }}</p>
                        <p class="zd-info-label">学校: {{ dialogData.school }}</p>
                        <p class="zd-info-label">学院: {{ dialogData.school_college }}</p>
                        <p class="zd-info-label">学历/学制: {{ dialogData.education_level | getEdu }}/{{ dialogData.max_grade }}年</p>
                        <p class="zd-info-label">入学年份: {{ dialogData.enter_school_year }}</p>
                        <p class="zd-info-label">专业: {{ dialogData.major }}</p>
                        <p class="zd-info-label">精英来源: {{ dialogData.apply_channel ? dialogData.apply_channel : '--' }}</p>
                        <p class="zd-info-label">上级姓名: {{ dialogData.parent_true_name }}</p>
                        <p class="zd-info-label">上级电话: {{ dialogData.parent_phone }}</p>
                        <p
                            class="zd-info-label"
                            v-if="agentType"
                        >
                            组织名称: {{ dialogData.org_name }}
                        </p>
                        <p
                            class="zd-info-label"
                            v-if="agentType">职务: {{ dialogData.org_duty }}</p>
                        <p
                            class="zd-info-label"
                            v-if="agentType">个人介绍: {{ dialogData.person_evaluation }}</p>
                        <p
                            class="zd-info-label"
                            v-if="agentType">对掌大认知: {{ dialogData.zsdx_knowledge }}</p>
                        <p
                            class="zd-info-label"
                            :style="{display: 'flex'}"
                        >
                            个人微信:
                            <el-image
                                :src="dialogData.person_qrcode"
                                :style="{width:'80px', cursor: 'pointer'}"
                                :preview-src-list="[ dialogData.person_qrcode ]"
                            />
                        </p>
                        <p
                            class="zd-info-label"
                            :style="{display: 'flex', flexWrap: 'wrap', width: '100%'}"
                        >
                            身份证明:
                            <el-image
                                v-for="(item,index) in dialogData.certificate_imag_list"
                                :key="index"
                                :src="item"
                                :style="{width:'80px', marginRight: '10px', cursor: 'pointer'}"
                                :preview-src-list="dialogData.certificate_imag_list"
                            />
                        </p>
                    </div>
                </div>
                <div
                    class="zd-examine-list"
                    style="align-items: center"
                    :style="{ 'pointerEvents' : dialog_status ? '' : 'none' }"
                >
                    <p class="zd-head-title">不通过理由:</p>
                    <el-input
                        type="textarea"
                        :autosize="{ minRows: 2, maxRows: 6}"
                        placeholder="请输入内容"
                        v-model="reason"
                    />
                </div>
                <div class="zd-foot">
                    <div class="zd-foot-left">
                        <el-button
                            type="primary"
                            size="mini"
                            style="margin-right: 10px"
                            @click="fnExamineAdopt(dialogData)"
                            v-if="dialog_status"
                        >
                            通过
                        </el-button>
                        <el-button
                            size="mini"
                            @click="fnExamineNoAdopt(dialogData, false)"
                            v-if="dialog_status"
                        >
                            不通过
                        </el-button>
                        <el-tag
                            type="info"
                            style="cursor: not-allowed"
                            v-if="!dialog_status && (dialogData.audit_status === 1) "
                        >
                            审核通过
                        </el-tag>
                        <el-tag
                            type="info"
                            style="cursor: not-allowed"
                            v-if="!dialog_status && (dialogData.audit_status === -1) "
                        >
                            审核未通过
                        </el-tag>
                    </div>
                    <div class="zd-foot-right">
                        <i class="el-icon-arrow-left"/>
                        <p
                            class="zd-foot-prev"
                            @click="fnPrevtData()"
                        >
                            上一条反馈
                        </p>
                        <p
                            class="zd-foot-next"
                            @click="fnNexttData()"
                        >
                            下一条反馈
                        </p>
                        <i class="el-icon-arrow-right"/>
                    </div>
                </div>
            </div>
        </el-dialog>

        <!-- 备注内容 -->
        <el-dialog
            title="备注内容"
            width="530px"
            custom-class="schedule-dialog"
            :visible.sync="showMask"
        >
            <el-form
                :model="ruleFormMask"
                :rules="rulesMask"
                ref="ruleFormMask"
            >
                <el-form-item
                    prop='reportCont'
                >
                    <el-input
                        type="textarea"
                        :autosize="{ minRows: 2, maxRows: 4}"
                        placeholder="请输入内容"
                        v-model="ruleFormMask.reportCont"
                    />
                </el-form-item>
            </el-form>
            <div
                slot="footer"
                class="dialog-footer"
            >
                <el-button
                    size="small"
                    type="primary"
                    @click="submitForm('ruleFormMask')">提交</el-button>
            </div>
        </el-dialog>
        <!-- 备注内容 -->

        <!-- 分页-批量操作 -->
        <div class="pagination-wrapper clearfix">
            <el-checkbox
                v-model="checkedAll"
                :indeterminate="checkIndeterminate"
                @change="fnChangeChecked"
            >全选</el-checkbox>
            <el-button
                type="text"
                @click="fnEliteExamkine()"
                :disabled="multipleSelection.length == 0 ? true : false"
            >批量审核通过</el-button>
            <el-pagination
                background
                layout="total, prev, pager, next"
                :current-page.sync="page.now_page"
                :total="page.total_count"
                :page-size="page.page_size"
                @current-change="getTableData"
            />
        </div>
        <!-- /分页-批量操作 -->

        <!-- 绑定客服 -->
        <el-dialog
            title="绑定客服"
            :visible.sync="dialogVisibleBind"
            width="580px"
            :close-on-click-modal="false"
            center
            class="dialogVisibleBind"
        >
            <el-form
                :model="ruleFormBind"
                label-width="100px"
                class="demo-ruleForm"
                @submit.native.prevent
            >
                <el-form-item
                    label="用户:"
                >
                    <el-input
                        v-model="ruleFormBind.phone"
                        size="small"
                        @keyup.native.enter="fnBindSearch()"
                        placeholder="手机号或用户ID"
                        :style="{'width': '350px'}"
                    />
                    <el-button
                        type="primary"
                        size="small"
                        @click="fnBindSearch()"
                    >
                        搜索
                    </el-button>
                </el-form-item>
                <el-table
                    :data="tableDataBind"
                    height="100%"
                    style="width: 100%;max-height:500px"
                    border
                    v-if="tableDataBind.length > 0"
                >
                    <el-table-column
                        label="用户姓名"
                        prop="true_name"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                    />
                    <el-table-column
                        label="电话号码"
                        prop="phone"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                    />
                    <el-table-column
                        label="学校名称"
                        prop="school_name"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                    />
                    <el-table-column
                        label="操作"
                        prop="school_name"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                    >
                        <template slot-scope="scope">
                            <span
                                @click="fnSelectKf(scope.row, true)"
                                class="el-delData"
                                v-if="!scope.row.flag"
                            >选择</span>
                            <span
                                @click="fnSelectKf(scope.row, false)"
                                class="el-delData"
                                v-if="scope.row.flag"
                            >已选</span>
                        </template>
                    </el-table-column>
                </el-table>
            </el-form>
            <span
                slot="footer"
                class="dialog-footer"
            >
                <el-button
                    @click="dialogVisibleBind = false"
                    size="small"
                >取 消</el-button>
                <el-button
                    type="primary"
                    size="small"
                    @click="fnConirmBind()">绑 定</el-button>
            </span>
        </el-dialog>
        <!-- /绑定客服 -->

        <!-- 解绑客服 -->
        <el-dialog
            title="解绑客服"
            :visible.sync="dialogVisibleUnBind"
            width="580px"
            :close-on-click-modal="false"
            center
            class="dialogVisibleBind"
        >
            <el-table
                :data="tableDataUnBind"
                height="100%"
                style="width: 100%;max-height:500px"
                border
                v-if="tableDataUnBind.length > 0"
            >
                <el-table-column
                    label="用户姓名"
                    prop="true_name"
                    show-overflow-tooltip
                    :formatter="emptyFormatter"
                />
                <el-table-column
                    label="电话号码"
                    prop="phone"
                    show-overflow-tooltip
                    :formatter="emptyFormatter"
                />
                <el-table-column
                    label="学校名称"
                    prop="school"
                    show-overflow-tooltip
                    :formatter="emptyFormatter"
                />
                <el-table-column
                    label="操作"
                    show-overflow-tooltip
                    :formatter="emptyFormatter"
                >
                    <template slot-scope="scope">
                        <span
                            @click="fnUnBindKf(scope.row)"
                            class="el-delData"
                        >解绑</span>
                    </template>
                </el-table-column>
            </el-table>
        </el-dialog>

        <!-- 图片预览 -->
        <img-preview ref="preview" />
    </div>
</template>

<script>
import { back } from '@/mixin/back';
import {getDate} from '@/assets/js/utils';
import imgPreview from '@/components/common/img-preview';
export default {
    /**
     * @param   {Boolean}    dialog_status          弹窗打开状态/true:审核false:查看
     * @param   {String}     reason                 不通过理由
     * @param   {Number}     pageSize               当页申请的条数
     * @param   {Boolean}    dialogVisible          审核和查看弹窗开关
     * @param   {Boolean}    checkIndeterminate     是否选中数据
     * @param   {Array}      multipleSelection      全选的数据
     * @param   {Boolean}    checkedAll             是否全选
     * @param   {Array}      examineList            筛选条件数据列表
     * @param   {Object}     head                   筛选字段
     * @param   {Object}     page                   分页
     * @param   {Array}      tableData              数据列表
     * @param   {OBject}     authResult             权限列表
     */
    mixins: [back],
    components: {
        imgPreview
    },
    data () {
        return {
            tableDataUnBind: [],//解绑客服数据
            dialogVisibleUnBind: false,//解绑客服弹窗开关
            ruleFormBind: {
                phone: ''
            },
            tableDataBind: [],//搜索客服数据
            dialogVisibleBind: false,//绑定客服弹窗开关
            is_kf: false,// 是否有客服
            is_kf_load: false,
            student_no: '', //记录编号
            ruleFormMask: {
                reportCont: ''
            },
            rulesMask: {
                reportCont: [
                    { required: true, message: '请填写备注内容', trigger: 'blur' }
                ]
            },
            showMask: false,
            dialogData: {},
            dialog_status: true,
            reason: '',
            pageIndex: 0,
            pageSize: 0,
            agentType: false,
            dialogVisible: false,
            checkIndeterminate: false,
            multipleSelection: [],
            checkedAll: false,
            examineList: [{
                value: '',
                label: '全部'
            },{
                value: -1,
                label: '未通过'
            },{
                value: 0,
                label: '待审核'
            },{
                value: 1,
                label: '已通过'
            }],
            head: {
                student_id_keyword: '',
                examine: '',
                date: ''
            },
            page: {
                now_page: 1,
                total_count: 0,
                page_size: 0
            },
            tableData: [],
            authResult: {}
        };
    },
    filters: {
        getEdu(val) {
            if(val == 1) {
                return '大专';
            } else if(val == 2) {
                return '本科';
            } else if(val == 3) {
                return '研究生';
            } else if(val == 4) {
                return '博士';
            } else {
                return;
            }
        },
        filterYear (val) {
            const year = new Date().getFullYear();

            return year - val;
        }
    },
    computed: {},
    watch: {
        dialogVisible(val) {
            if(!val) {
                this.reason = '';
            }
        },
        showMask (val) {
            if(!val) {
                this.ruleFormMask.reportCont = '';
            }
        }
    },
    mounted () {
        this.$store.commit('SET_HEADER', [{ title: "APP后台"},{title: '掌大精英'},{title: '精英审核提交'}]);
        this.authResult = this.$route.meta.authResult;

        const query = this.$route.query;

        if(query.keyword !== undefined) {
            this.head.student_id_keyword = query.keyword;
        }
        if(query.audit_status !== undefined) {
            this.head.examine = query.audit_status;
        }
        this.getTableData();
        this.getKfData();
    },
    methods: {
        /**
         * 获取表格数据
         */
        getTableData (page) {
            this.$post('/student/stuagent_apply%5Cget_list', {
                page_id: page || this.page.now_page,
                keyword: this.head.student_id_keyword,
                audit_status: this.head.examine,
                time_range: this.head.date === '' || this.head.date === null ? '' : getDate(new Date(this.head.date[0])) + '-' + (getDate(new Date(this.head.date[1])) + 86400)
            }, resp => {
                if (resp.code == 1) {
                    this.tableData = resp.data.list;
                    this.page.now_page = resp.data.page.now_page;
                    this.page.total_count = resp.data.page.total_count;
                    this.page.page_size = resp.data.page.page_size;

                    //计算当前页数据数量
                    if(resp.data.page.total_count == 1) {
                        this.pageSize = resp.data.page.total_count;
                    } else if (resp.data.page.total_count > 1 && resp.data.page.next_page > 0) {
                        this.pageSize = 20;
                    } else if (resp.data.page.total_count > 1 && resp.data.page.next_page == 0) {
                        this.pageSize = resp.data.page.total_count - (resp.data.page.now_page - 1) * 20;
                    }
                }
            });
        },

        /**
         * 获取客服数据
         */
        getKfData () {
            this.$post('/student/stuagent_apply%5Cget_contact',{},resp=>{
                this.is_kf = resp.data === null ? false : true;
                this.is_kf_load = true;

                if(this.is_kf) {
                    this.tableDataUnBind = [{
                        phone: resp.data.phone,
                        school: resp.data.school,
                        student_no: resp.data.student_no,
                        true_name: resp.data.true_name
                    }];
                }
            });
        },

        /**
         * 解绑客服
         */
        fnUnBindKf (row) {
            this.$post('/student/stuagent_apply%5Cclear_contact',{
                student_no: row.student_no
            },resp=>{
                if (resp.code == 1) {
                    this.$message({
                        type: 'success',
                        message: '解绑成功',
                        center: true
                    });
                    this.dialogVisibleUnBind = !this.dialogVisibleUnBind;
                    this.is_kf = !this.is_kf;
                } else if (resp.code == 0) {
                    this.$message({
                        type: 'waring',
                        message: resp.msg,
                        center: true
                    });
                }
            });
        },

        /**
         * 确定绑定客服
         */
        fnConirmBind () {
            this.$post('/student/stuagent_apply%5Cset_contact',{
                student_no: this.student_no
            },resp=>{
                if (resp.code == 1) {
                    this.getKfData();
                    this.dialogVisibleBind = !this.dialogVisibleBind;
                    this.$message({
                        type: 'success',
                        message: '绑定成功',
                        center: true
                    });
                } else if (resp.code == 0) {
                    this.$message({
                        type: 'waring',
                        message: resp.msg,
                        center: true
                    });
                }
            });
        },

        /**
         * 设置客服
         */
        fnSetkf () {
            if(!this.is_kf) {
                this.dialogVisibleBind = !this.dialogVisibleBind;
            } else {
                this.dialogVisibleUnBind = !this.dialogVisibleUnBind;
            }
        },

        /**
         * 搜索
         */
        fnBindSearch () {
            this.$post('/student/student_user%5Cget_list_suggest',{
                keyword: this.ruleFormBind.phone
            },resp=>{
                if (resp.code == 1) {
                    if (resp.data.list.length == 0) {
                        this.$message({
                            type: 'waring',
                            message: '该用户不存在'
                        });
                        this.ruleFormBind.phone = '';
                        return;
                    }
                    this.tableDataBind = resp.data.list;
                    this.ruleFormBind.phone = '';
                } else if (resp.code == 0) {
                    this.$message({
                        type: 'waring',
                        message: resp.msg
                    });
                }
            });
        },

        /**
         * 选择客服
         */
        fnSelectKf (row, type) {
            if(this.student_no && this.student_no !== row.student_no) {
                this.$message({
                    type: 'waring',
                    message: '仅可选择一个',
                    center: true
                });
                return;
            }

            if(this.student_no && this.student_no == row.student_no) {
                this.student_no = '';
            } else {
                this.student_no = row.student_no;
            }

            this.$set(row,'flag', type);
        },

        /**
         * 上一条
         */
        fnPrevtData () {
            if(this.pageIndex == 0) {
                this.$message({
                    type: 'waring',
                    message: '当前已经是第一条了',
                    center: true
                });
                return;
            }

            this.pageIndex--;
            this.dialogData = this.tableData[this.pageIndex];
            this.agentType = this.dialogData.agent_type == 2 ? true : false;
            this.dialog_status = this.dialogData.audit_status == 0 ? true : false;
            if(!this.dialog_status) {
                this.reason = this.dialogData.audit_reason;
            }
        },

        /**
         * 下一条
         */
        fnNexttData () {
            if(this.pageIndex == this.pageSize - 1) {
                this.$message({
                    type: 'waring',
                    message: '当前已经是最后一条了',
                    center: true
                });
                return;
            }
            this.pageIndex++;
            this.dialogData = this.tableData[this.pageIndex];
            this.agentType = this.dialogData.agent_type == 2 ? true : false;
            this.dialog_status = this.dialogData.audit_status == 0 ? true : false;
            if(!this.dialog_status) {
                this.reason = this.dialogData.audit_reason;
            }
        },

        /**
         * 打开备注弹窗
         */
        fnBeizhu (row) {
            this.student_no = row.student_no;
            this.showMask = !this.showMask;
        },

        /**
         * 提交备注
         */
        submitForm (formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    this.$post('/student/stuagent_apply%5Cset_remark',{
                        student_no: this.student_no,
                        remark: this.ruleFormMask.reportCont
                    },resp=>{
                        if (resp.code == 1) {
                            this.getTableData();
                            this.showMask = !this.showMask;
                            this.$message({
                                type: 'success',
                                message: '提交成功',
                                center: true
                            });
                        } else if (resp.code == 0) {
                            this.$message({
                                type: 'warning',
                                message: resp.msg,
                                center: true
                            });
                        }
                    });
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },


        /**
         * 审核
         */
        fnEXamlineDialog (row, index) {
            this.dialogData = {
                ...row
            };
            this.agentType = this.dialogData.agent_type == 2 ? true : false;
            this.pageIndex = index;
            this.dialog_status = true;
            this.dialogVisible = !this.dialogVisible;
        },

        /**
         * 查看
         */
        fnSeeDialog (row, index) {
            this.dialogData = {
                ...row
            };
            this.agentType = row.agent_type == 2 ? true : false;
            this.reason = row.audit_reason;
            this.dialog_status = false;
            this.pageIndex = index;
            this.dialogVisible = !this.dialogVisible;
        },

        /**
         * 审核通过
         */
        fnExamineAdopt (row) {
            this.$confirm('是否确定通过审核？', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$post('/student/stuagent_apply%5Caudit_pass',{
                    student_nos: row.student_no
                }, resp => {
                    if (resp.code == 1) {
                        this.dialog_status = false;
                        this.dialogData = this.tableData[this.pageIndex];
                        this.$set(this.dialogData, 'audit_status', 1);
                        this.getTableData();
                        this.$message({
                            type: 'success',
                            message: '操作成功',
                            center: true
                        });
                    } else {
                        this.$message({
                            type: 'waring',
                            message: resp.msg,
                            center: true
                        });
                    }
                });
            });
        },

        /**
         * 审核不通过
         */
        fnExamineNoAdopt (row, type) {
            if(type) {
                this.$prompt('请输入不通过原因', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    inputPattern: /\S/,
                    inputErrorMessage: '内容不可以为空'
                }).then(({ value }) => {
                    this.$post('/student/stuagent_apply%5Caudit_fail',{
                        student_no: row.student_no,
                        audit_reason: value
                    }, resp => {
                        if (resp.code == 1) {
                            this.getTableData();
                            this.dialog_status = false;
                            this.$message({
                                type: 'success',
                                message: '操作成功',
                                center: true
                            });
                        } else {
                            this.$message({
                                type: 'waring',
                                message: resp.msg,
                                center: true
                            });
                        }
                    });
                });
            }

            if(!type) {
                if (this.reason == '') {
                    this.$message({
                        type: 'waring',
                        message: '请填写不通过理由,不可以为空',
                        center: true
                    });
                    return;
                } else {
                    this.$post('/student/stuagent_apply%5Caudit_fail',{
                        student_no: this.dialogData.student_no,
                        audit_reason: this.reason
                    }, resp => {
                        if (resp.code == 1) {
                            this.getTableData();
                            this.dialog_status = false;
                            this.dialogData = this.tableData[this.pageIndex];
                            this.$set(this.dialogData, 'audit_status', -1);
                            this.$message({
                                type: 'success',
                                message: '操作成功',
                                center: true
                            });
                        } else {
                            this.$message({
                                type: 'waring',
                                message: resp.msg,
                                center: true
                            });
                        }
                    });
                }
            }
        },

        /**
         * 批量审核通过
         */
        fnEliteExamkine () {
            if(this.multipleSelection.length > 0) {
                let student_nos = [];

                this.multipleSelection.map(item=>{
                    student_nos.push(item.student_no);
                });

                this.$post('/student/stuagent_apply%5Caudit_pass',{
                    student_nos: student_nos.join()
                }, resp => {
                    if (resp.code == 1) {
                        this.getTableData();
                        this.$message({
                            type: 'success',
                            message: '操作成功',
                            center: true
                        });
                    } else {
                        this.$message({
                            type: 'waring',
                            message: resp.msg,
                            center: true
                        });
                    }
                });
            }
        },

        /**
         * 全选逻辑操作
         */
        fnSelect(selection) {
            if(selection.length == this.tableData.length) {
                this.checkedAll = true;
            }else{
                this.checkedAll = false;
            }
            if(selection.length > 0 && selection.length < this.tableData.length) {
                this.checkIndeterminate = true;
            }else{
                this.checkIndeterminate = false;
            }
        },
        fnSelectAllTop(selection) {
            if(selection.length > 0) {
                this.checkedAll = true;
            }else{
                this.checkedAll = false;
            }
            if(selection.length > 0 && selection.length < this.tableData.length) {
                this.checkIndeterminate = true;
            }else{
                this.checkIndeterminate = false;
            }
        },
        fnChangeChecked() {
            if(this.checkedAll){
                this.toggleSelection(1);
            }else{
                this.toggleSelection();
            }
        },
        toggleSelection(rows) {
            if (rows) {
                this.$refs.eliteExamline.toggleAllSelection();
            } else {
                this.$refs.eliteExamline.clearSelection();
            }
        },
        handleSelectionChange(val) {
            this.multipleSelection = val;
        },

        /**
         * @description 查看图片
         * @param   {String}    images    单图预览
         * @param   {Array}     images     多图预览
         */
        fnShowPreview(images) {
            if(images && Object.prototype.toString.call(images) == '[object String]') {
                this.$refs.preview.show([
                    images
                ]);
            } else if (images && Object.prototype.toString.call(images) == '[object Array]') {
                this.$refs.preview.show(images);
            } else {
                this.$notify({
                    title: '提示',
                    message: '图片类型错误',
                    type: 'warning',
                    duration: 2000
                });
            }
        },

        /**
         * 过滤函数
         */
        emptyFormatter(row, column, val) {
            if (!val) return '--';
            return val;
        }
    }
};
</script>

<style lang="less" scoped>
    .container {
        background-color: #fff;
        padding: 10px 15px 5px 15px;
        display: flex;
        flex-direction: column;
        position: relative;
        width: 100%;
        .header-nav {
            position: relative;
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            justify-content: space-between;
            .header-left, .header-right {
                display: flex;
                align-items: center;
                margin-bottom: 10px;
            }
            .header-new-box {
                display: flex;
                margin-right: 15px;
                align-items: center;
                color: #606266;
                &-title {
                    margin-right: 2px;
                    white-space: nowrap;
                }
            }
        }
        /* 表单 */
        .scope-price {
            width: 50px;
            height: 50px;
        }
        /* 字体高亮 */
        .cursor-font {
            color: rgb(64, 158, 255);
            cursor: pointer;
        }
        /* 分页 */
        .pagination-wrapper {
            padding-top: 10px;
            padding-bottom: 10px;
            .el-pagination {
                float: right;
                padding: 0;
                background-color: transparent;
            }
        }
    }
    /* 排序 */
    .sort-wrap {
        display: flex;
        align-items: center;
        cursor: pointer;
        .sort-spliter {
            width: 1px;
            height: 12px;
            background: rgba(235, 235, 235, 1);
            margin: 0 10px;
            }
            .btn-sort {
            font-size: 14px;
            line-height: 1;
            color: #ccc;
            &:hover {
                color: #20a0ff;
            }
        }
    }
    .el-button-left {
        margin-left: 40px;
    }
    .el-button-right {
        margin-right: 10px;
    }
    /* 审核弹窗 */
    .zd-examine {
        width: 100%;
        .zd-examine-list {
            min-height: 20px;
            display: flex;
            padding-bottom: 30px;
            box-sizing: border-box;
            align-items: flex-start;
            .zd-head-title {
                color: #606285;
                font-size: 14px;
                margin-right: 20px;
                white-space: nowrap;
                width: 65px;
            }
            .zd-info {
                width: 400px;
                display: flex;
                flex-wrap: wrap;
                .zd-info-label {
                    width: 200px;
                    min-height: 20px;
                    font-size: 14px;
                    color: #333;
                    margin-bottom: 15px;
                }
            }
            .zd-examine-line {
                width: 200px;
                height: 12px;
                border-radius: 6px;
                background: rgba(64, 158, 255, .2);
                .zd-examine-line-length {
                    height: 12px;
                    border-radius: 6px;
                    background: rgba(64, 158, 255, 1);
                    transition: all .5s;
                }
            }
            .zd-examine-page {
                font-size: 14px;
                color: #333;
                margin-left: 10px;
            }
        }
        .zd-foot {
            display: flex;
            justify-content: space-between;
            .zd-foot-left, .zd-foot-right {
                display: flex;
                height: 32px;
                align-items: center;
                cursor: pointer;
                user-select:none;
                .zd-foot-prev {
                    font-size: 14px;
                    color: #333;
                    margin-right: 15px;
                    // &:hover {
                    //     color: #20a0ff;
                    // }
                }
                .zd-foot-next {
                    font-size: 14px;
                    color: #333;
                    // &:hover {
                    //     color: #20a0ff;
                    // }
                }
            }
        }
    }
    .el-delData {
        color: #409EFF;
        cursor: pointer;
    }
</style>
<style lang="less">
    .eliteExamline{
        .el-table__body-wrapper .el-table__body .el-table__row td {
            border-right: none;
        }
        .el-table__header-wrapper .el-table__header .has-gutter tr th {
            border-right: none;
        }
        .el-table .el-table_1_column_6  .cell {
            position: relative;
        }
        .el-range-editor--small .el-range-separator{
            padding: 0 1px !important;
        }
    }
    .el-image-viewer__wrapper {
        z-index: 9999!important;
    }
</style>
